<template>
    <div id="upload">        
        <div class="product-shop">
            <div class="upload-image" id="upload">
                <div class="img-left">
                    <span id="txt" v-if="upno">Upload A Picture</span>
                    <img :src="iAsrc" id="PreviewPicture" :class="{active:isActive}" />
                </div>
                <div class="img-right">
                    <input class="avatar-input" type="file" id="inputImage0" @change="reads" />
                    <label for="inputImage0">uploading</label>
                </div>
            </div>
            <select class="single-option-selector" id="OptionSelector" data-index="0" data-option="option1" data-name="Color">
                <option value="">-- Choose Your Color --</option>
                <option value="Blue">Blue</option>
                <option value="Green">Green</option>
                <option value="Pink">Pink</option>
                <option value="Purple">Purple</option>
                <option value="Red">Red</option>
                <option value="White">White</option>
                <option value="Black">Black</option>
                <option value="Grey">Grey</option>
                <option value="Orange">Orange</option>
                <option value="Smoky blue">Smoky blue</option>
            </select>            
        </div>
        <Vupload></Vupload>
    </div>
</template>
<script>
import Vupload from './upload/media.vue'
export default {
    name:'upload',
    components:{
        Vupload
    },
    data(){
        return {
            iAsrc:'',
            upno:true,
            isActive:false
        }
    },
    methods: {
        reads(e){
            this.files = e.target.files[0];
            let reader = new FileReader();            
            reader.readAsDataURL(this.files);//发起异步请求            
            let that = this;       
            this.upno=false;  
            this.isActive = true;   
            reader.onload = function(){
                //读取完成后，将结果赋值给img的src
                that.iAsrc = this.result;
                
            }            
        }
    }
}
</script>
<style>

.single-option-selector{
	font-size: 12px;
    height: 50px;
    width: 100%;
    background: #f8f8f8;
    border: 1px solid #e7e7e7;
    color: #000;    
}
.upload-image{
	height: 50px;
    display: flex;
    background: #f8f8f8;
    align-items: center;
    border: 1px solid #e7e7e7;
    margin-bottom:10px;
}
.img-left,.img-right{
	width: 50%;
	height: 100%;
	overflow: hidden;
}
.img-left{
	text-align: left;
    padding-left: 10px;
    display: flex;
    justify-content: left;
    align-items: center;
    font-size: 12px;
    color: #000;
}
.img-right{
display: flex;
align-items: center;
position: relative;
height: 100%;
}
#PreviewPicture{
	max-height: 45px;	
}
.img-right .avatar-input{
	position: absolute;
	left: 0;top: 0;right: 0;bottom: 0;
	opacity: 0;
	width: 100%;
}
.img-right label{
	background: #000;
	color: #fff;
	position: absolute;
	right: 6px;
	font-size: 12px;
	top: 25%;
	padding: 3px 10px 5px;
	border-radius: 20px;	
}
#modal{
	position: fixed;
	left: 0;top: 0;bottom: 0;right: 0;
	background: rgba(0,0,0,.7);	
	justify-content: center;
	align-items: center;
	display: none;
}
.modal-content{
	width: 600px;
	height: 500px;
	background: #fff;	
}
.modal-header{
	margin-bottom: 50px;
}
.modal-box{
	padding:0 50px 50px;
}
.modal-content img {
	width: 100%;
}
.modal-header span {
	font-size: 24px;
	padding-right: 10px;
	cursor: pointer;
}
</style>

